<?php

class Default_Model_Convertid extends Zend_Db_Table_Abstract
{
    protected $_name;
    public $_configGame;
    public function __construct($gameId = null, $channel)
    {
        if(!file_exists(CONFIG_PATH . '/'.$gameId.'.ini')){
            die('Config game not found!!!');
        }
      
        $configGame     = new Zend_Config_Ini(CONFIG_PATH . '/'.$gameId.'.ini', APPLICATION_ENV);
       
        $this->_configGame = $configGame;
        if(!isset($configGame->convertid->$channel)){
            die('Config db not found!!!');
        }
        $this->_name = $configGame->convertid->$channel->params->table;
    	$db = $configGame->convertid->$channel;
		$db = Zend_Db::factory($db->adapter, $db->params);
        $this->_setAdapter($db);
    }
    public function getData($userId){
        $query = $this->select()
                    ->from($this->_name, array('id','username'))
                    ->where("id = ?", $userId);
        return $this->fetchRow($query);
    }
    public function checkUserName($userName)
    {
        $query = $this->select()
                    ->from($this->_name, array('id','username'))
                    ->where("username like ?", $userName.'%');
        return $this->fetchRow($query);
    }

}